<template>
  <div class="login">
    <div style="width: 500px;height: 400px;border: 1px solid #24292f;border-radius: 10px">
      <div style="display: flex;width: 100%;justify-content: center;font-size: 30px;font-weight: 700">
        <p>登录</p>
      </div>
      <div style="display: flex;justify-content: center;margin-bottom: 20px">
        <span style="line-height: 30px;width: 70px">网站地址：</span>
        <div style="width: 350px">
          <a-input v-model:value="addressUrl"></a-input>
        </div>
      </div>
      <div style="display: flex;justify-content: center;margin-bottom: 20px">
        <span style="line-height: 30px;width: 70px;">用户名：</span>
        <div style="width: 350px">
          <a-input v-model:value="username"></a-input>
        </div>
      </div>
      <div style="display: flex;justify-content: center;margin-bottom: 50px">
        <span style="line-height: 30px;width: 70px">密码：</span>
        <div style="width: 350px">
          <a-input-password v-model:value="password"></a-input-password>
        </div>
      </div>
      <div style="display: flex;justify-content: center;">
        <a-button @click="Login">登录</a-button>
      </div>
    </div>
  </div>
</template>

<script>
import {ref} from 'vue'
import {message} from "ant-design-vue";
import {useRouter} from "vue-router";

export default {
  name: "Login",
  setup() {
    const router = useRouter()
    let addressUrl = ref('')
    let username = ref('')
    let password = ref('')
    const Login = () => {
      window.go.main.App.Login(addressUrl.value, username.value, password.value).then(res => {
        if (res.code === 200) {
          message.success("登录成功")
          router.push('/')
        } else {
          message.error("登录失败")
        }
      })
    }
    return {
      addressUrl,
      username,
      password,
      Login
    }
  }
}
</script>

<style scoped>
.login {
  height: calc(100% - 25px);
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>